package com.rabbit.util;

import cn.hutool.extra.servlet.ServletUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * <h1>IP地址工具类</h1>
 *
 * @author zjw
 * @date 2022/01/24 22:30
 */
public class IpUtil {

    /**
     * 获取IP地址
     *
     * @param request HttpServletRequest
     * @return String IP地址
     */
    public static String getClientIP(HttpServletRequest request) {
        String clientIp = ServletUtil.getClientIP(request);
        return Objects.equals(clientIp, "0:0:0:0:0:0:0:1") ? "127.0.0.1" : clientIp;
    }

}
